<template>
  <nav class="site-navbar" :class="'site-navbar--' + navbarLayoutType">
    <div class="site-navbar__header">
      <h1 class="site-navbar__brand" @click="$router.push({ name: 'home' })">
        <img src="~@/assets/img/logo-0f63b8.png" alt="" class="" />
        <!-- <a class="site-navbar__brand-lg" href="javascript:;">筑品行供应链管理系统</a>
        <a class="site-navbar__brand-mini" href="javascript:;">筑品行</a> -->
      </h1>
    </div>
    <div class="site-navbar__body clearfix">
      <el-menu class="site-navbar__menu" mode="horizontal">
        <!-- <el-menu-item class="site-navbar__switch" index="0" @click="sidebarFold = !sidebarFold">
          <icon-svg name="zhedie"></icon-svg>
        </el-menu-item> -->
        <el-menu-item
          class="site-navbar__switch"
          index="0"
        >
          <!-- <div class="circle"></div> -->
          <span class="tit">你好，欢迎来到筑品行供应链管理系统！</span>
        </el-menu-item>
      </el-menu>
      <el-menu
        class="site-navbar__menu site-navbar__menu--right"
        mode="horizontal"
      >
        <el-menu-item index="1">
          <!-- <el-badge class="inp searchinp">
            
          </el-badge> -->
          <el-input
              placeholder="搜索产品功能"
              prefix-icon="el-icon-search"
              v-model="input2"
            ></el-input>
        </el-menu-item>
        <el-menu-item index="2" @click="$router.push({ name: 'theme' })">
          <template slot="title">
            <el-badge>
              <!-- <icon-svg name="shezhi" class="el-icon-setting"></icon-svg> -->
              <svg t="1604562401490" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1021" width="200" height="200"><path d="M775.757576 868.848485c0-9.309091 6.206061-15.515152 15.515151-15.515152h155.151515c9.309091 0 15.515152 6.206061 15.515152 15.515152s-6.206061 15.515152-15.515152 15.515151h-155.151515c-9.309091 0-15.515152-6.206061-15.515151-15.515151z" p-id="1022" fill="#ffffff"></path><path d="M946.424242 899.878788h-155.151515c-18.618182 0-31.030303-12.412121-31.030303-31.030303s12.412121-31.030303 31.030303-31.030303h155.151515c18.618182 0 31.030303 12.412121 31.030303 31.030303s-12.412121 31.030303-31.030303 31.030303z m-170.666666-31.030303h15.515151-15.515151z" p-id="1023" fill="#ffffff"></path><path d="M62.060606 868.848485c0-9.309091 6.206061-15.515152 15.515152-15.515152h155.151515c9.309091 0 15.515152 6.206061 15.515151 15.515152s-6.206061 15.515152-15.515151 15.515151H77.575758c-9.309091 0-15.515152-6.206061-15.515152-15.515151z" p-id="1024" fill="#ffffff"></path><path d="M232.727273 899.878788H77.575758c-18.618182 0-31.030303-12.412121-31.030303-31.030303s12.412121-31.030303 31.030303-31.030303h155.151515c18.618182 0 31.030303 12.412121 31.030303 31.030303s-12.412121 31.030303-31.030303 31.030303zM62.060606 868.848485H77.575758 62.060606z" p-id="1025" fill="#ffffff"></path><path d="M403.393939 992.969697c0-9.309091 6.206061-15.515152 15.515152-15.515152h186.181818c9.309091 0 15.515152 6.206061 15.515152 15.515152s-6.206061 15.515152-15.515152 15.515151h-186.181818c-9.309091 0-15.515152-6.206061-15.515152-15.515151z" p-id="1026" fill="#ffffff"></path><path d="M605.090909 1024h-186.181818c-18.618182 0-31.030303-12.412121-31.030303-31.030303s12.412121-31.030303 31.030303-31.030303h186.181818c18.618182 0 31.030303 12.412121 31.030303 31.030303s-12.412121 31.030303-31.030303 31.030303z m-201.69697-31.030303h15.515152-15.515152z" p-id="1027" fill="#ffffff"></path><path d="M512 15.515152c9.309091 0 15.515152 6.206061 15.515152 15.515151v62.060606c0 9.309091-6.206061 15.515152-15.515152 15.515152s-15.515152-6.206061-15.515152-15.515152V31.030303c0-9.309091 6.206061-15.515152 15.515152-15.515151z" p-id="1028" fill="#ffffff"></path><path d="M512 124.121212c-18.618182 0-31.030303-12.412121-31.030303-31.030303V31.030303c0-18.618182 12.412121-31.030303 31.030303-31.030303s31.030303 12.412121 31.030303 31.030303v62.060606c0 18.618182-12.412121 31.030303-31.030303 31.030303z m0-108.60606V31.030303 15.515152z" p-id="1029" fill="#ffffff"></path><path d="M884.363636 899.878788H139.636364V465.454545C139.636364 260.654545 307.2 93.090909 512 93.090909s372.363636 167.563636 372.363636 372.363636v434.424243zM201.69697 837.818182h620.60606V465.454545c0-170.666667-139.636364-310.30303-310.30303-310.30303S201.69697 294.787879 201.69697 465.454545v372.363637z" p-id="1030" fill="#ffffff"></path></svg>
            </el-badge>
          </template>
        </el-menu-item>
        <!-- <el-menu-item index="2">
          <el-badge value="hot">
            <a href="https://www.renren.io/" target="_blank">官方社区</a>
          </el-badge>
        </el-menu-item>
        <el-submenu index="3">
          <template slot="title">Git源码</template>
          <el-menu-item index="2-1"><a href="https://github.com/renrenio/renren-fast-vue" target="_blank">前端</a></el-menu-item>
          <el-menu-item index="2-2"><a href="https://gitee.com/renrenio/renren-fast" target="_blank">后台</a></el-menu-item>
          <el-menu-item index="2-3"><a href="https://gitee.com/renrenio/renren-generator" target="_blank">代码生成器</a></el-menu-item>
        </el-submenu> -->
        <el-menu-item class="site-navbar__avatar" index="3">
          <el-dropdown :show-timeout="0" placement="bottom">
            <span class="el-dropdown-link">
              <img src="~@/assets/img/avatar.png" :alt="userName" />{{
                userName
              }}
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item @click.native="updatePasswordHandle()"
                >修改密码</el-dropdown-item
              >
              <el-dropdown-item @click.native="logoutHandle()"
                >退出</el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
        </el-menu-item>
      </el-menu>
    </div>
    <!-- 弹窗, 修改密码 -->
    <update-password
      v-if="updatePassowrdVisible"
      ref="updatePassowrd"
    ></update-password>
  </nav>
</template>

<script>
import UpdatePassword from "./main-navbar-update-password";
import { clearLoginInfo } from "@/utils";
export default {
  data() {
    return {
      updatePassowrdVisible: false,
      input2:''
    };
  },
  components: {
    UpdatePassword,
  },
  computed: {
    navbarLayoutType: {
      get() {
        return this.$store.state.common.navbarLayoutType;
      },
    },
    sidebarFold: {
      get() {
        return this.$store.state.common.sidebarFold;
      },
      set(val) {
        this.$store.commit("common/updateSidebarFold", val);
      },
    },
    mainTabs: {
      get() {
        return this.$store.state.common.mainTabs;
      },
      set(val) {
        this.$store.commit("common/updateMainTabs", val);
      },
    },
    userName: {
      get() {
        return this.$store.state.user.name;
      },
    },
  },
  methods: {
    // 修改密码
    updatePasswordHandle() {
      this.updatePassowrdVisible = true;
      this.$nextTick(() => {
        this.$refs.updatePassowrd.init();
      });
    },
    // 退出
    logoutHandle() {
      this.$confirm(`确定进行[退出]操作?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl("/sys/logout"),
            method: "post",
            data: this.$http.adornData(),
          }).then(({ data }) => {
            if (data && data.code === 0) {
              clearLoginInfo();
              this.$router.push({ name: "login" });
            }
          });
        })
        .catch(() => {});
    },
  },
};
</script>
<style>
.site-navbar {
  height: 90px;
}
.site-navbar__header {
  height: 90px;
}
.site-navbar__brand {
  line-height: 90px;
}
.site-navbar__menu .el-menu-item,
.site-navbar__menu .el-submenu > .el-submenu__title {
  height: 90px;
  line-height: 90px;
}
.searchinp {
  width: 220px;
  height: 36px;
  background: #e8eaee;
  border-radius: 18px;
}
.site-navbar--inverse .el-menu .el-menu-item i, .site-navbar--inverse .el-menu .el-submenu__title i, .site-navbar--inverse .el-menu .el-dropdown {
    color: #999;
    position: raelative;
    left: 1;
}
.icon{
  width: 24px;
  height: 24px;
}
</style>
